﻿Imports System.Web
Imports System.Security.Principal



Public Class HttpServiceProvider
    Implements IServiceProvider

    Protected _httpContext As HttpContextBase

    Public Sub New(ByVal htpc As HttpContextBase)
        _httpContext = htpc
    End Sub

    Public Function GetService(ByVal serviceType As System.Type) As Object Implements System.IServiceProvider.GetService
        If (IsNothing(serviceType)) Then
            Throw New ArgumentNullException("serviceType")
        End If
        If (serviceType Is GetType(IPrincipal)) Then
            Return _httpContext.User
        End If
        If (serviceType Is GetType(HttpContextBase)) Then
            Return _httpContext
        End If
        Return Nothing

    End Function
End Class
